<?php
abstract class FiltreBase
{
	public function __construct($regexp)
	{
		$this->regexp = $regexp;
	}

	public function init() {
	}

	public function prerequis() {
		return true;
	}

	public function destroy() {
	}

	public function exec(&$texte)
	{
		$search = array();
		$repl = array();

		if (preg_match_all($this->regexp, $texte, $matches, PREG_SET_ORDER)) {

			foreach($matches as $match) {

				$search[] = $match[0];
				$repl[] = $this->calcule($match);
			}

			$texte = str_replace($search, $repl, $texte);
		}
	}

	public abstract function calcule($match);
}
?>